package com.framework.web.bus.service;
import com.framework.web.bus.domain.DeliveryArea;
import com.framework.web.bus.repository.DeliveryAreaRepository;
import com.framework.web.bus.repository.specifications.DeliveryAreaSpecs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @Title: Service
* @Description: 业务层
* @author zqtao
* @date 2016-09-29
* @version V1.0
*
*/
@Service
public class DeliveryAreaService {

@Autowired
private DeliveryAreaRepository  deliveryAreaRepository;

/**
* 新增或者保存
* @param deliveryArea
* @return
*/
public DeliveryArea save(DeliveryArea deliveryArea) {
    return deliveryAreaRepository.save(deliveryArea);
}

/**
* 删除
* @param id
*/
public void  delete(String id) {
    deliveryAreaRepository.delete(id);
}
/**
* 根据id查询
* @param id
* @return
*/
public DeliveryArea findById(String id) {
    return deliveryAreaRepository.findOne(id);
}


/**
* 分页查找
* @param deliveryArea
* @param pr
* @return
*/
public Page<DeliveryArea> getPageList(DeliveryArea deliveryArea, PageRequest pr) {
    Page<DeliveryArea> totalList = deliveryAreaRepository.findAll(DeliveryAreaSpecs.pageQueryDeliveryArea(deliveryArea), pr);
    return totalList;
}


public List<DeliveryArea> findByTypeId(String typeId){
    return deliveryAreaRepository.findByTypeId(typeId);
}

}
